package se.webbzon.boltzmann.menu;

import java.awt.image.ImageObserver;

public class OptionPage extends MFlowPage {
	
	// The layout of this page
	private final AbstractGameMenuLayout layout;

	/*============================================================
	Constructors
	============================================================*/
	
	public OptionPage(ImageObserver observer, AbstractGameMenuLayout layout, MPage parent) {
		super(observer,layout.getPageLayout(),parent,"Options");
		this.layout = layout;
		addItem(new PageLabel(observer, layout.getLabelLayout(),this));
		addRow(0.25);
		addItem(new ReturnButton(observer,layout.getButtonLayout(), parent));
		addRow();
		addItem(new GraphicsButton(layout.getButtonLayout()));
		addRow();
		addItem(new ControlsButton(layout.getButtonLayout()));
		addRow();
		addItem(new AudioButton(layout.getButtonLayout()));
	}
	
	/*============================================================
	Public Methods
	============================================================*/

	@Override public void onEnter(GameMenu menu) {}

	@Override public void onLeave(GameMenu menu) {}
	
	/*============================================================
	Private Classes
	============================================================*/
	
	private final class GraphicsButton extends MButton {

		public GraphicsButton(ButtonLayout layout) {
			super(getImageObserver(), layout, false, "Graphics");
		}

		@Override public void onClick(GameMenu menu) {
			menu.setPage(new GraphicPage(getImageObserver(), layout,OptionPage.this));
		}
		
	}
	
	private final class ControlsButton extends MButton {

		public ControlsButton(ButtonLayout layout) {
			super(getImageObserver(), layout, false, "Controls");
		}

		@Override public void onClick(GameMenu menu) {
			menu.setPage(new ControlPage(getImageObserver(), layout,OptionPage.this));
		}
		
	}
	
	private final class AudioButton extends MButton {

		public AudioButton(ButtonLayout layout) {
			super(getImageObserver(), layout, false, "Audio");
		}

		@Override public void onClick(GameMenu menu) {
			menu.setPage(new AudioPage(getImageObserver(), layout,OptionPage.this));
		}
		
	}

}
